<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>worker performance optimization</title>
</head>
<body>
    <script>
        function runWorker(url, num) {
            return new Promise((resolve, reject) => {
                const worker = new Worker(url);
                worker.postMessage(num);
                worker.addEventListener('message', function (evt) {
                    resolve(evt.data);
                });
                worker.onerror = reject;
            })
        }
        runWorker('./worker.js', 10*10000*10000).then(res => {
            document.write(res);
        });        
    </script>
</body>
</html>
